//
//  ProgressImageView.swift
//  Weibo
//
//  Created by 李亚乐 on 15/12/20.
//  Copyright © 2015年 李亚乐. All rights reserved.
//

import UIKit

class ProgressView: UIView {
    var progress: CGFloat = 0 {
        didSet {
            setNeedsDisplay()
        }
    }
    
    internal override func drawRect(rect: CGRect) {
        
        let arcCenter = CGPoint(x: rect.width / 2, y: rect.height / 2)
        let radius = min(rect.width, rect.height) / 2
        let starAngle = CGFloat(-M_PI_2)
        let endAngle = starAngle + 2 * CGFloat(M_PI) * progress

        
        //圆弧路径
        let path = UIBezierPath(arcCenter: arcCenter, radius: radius, startAngle: starAngle, endAngle: endAngle, clockwise: true)
        
        path.addLineToPoint(arcCenter)
        path.closePath()

        UIColor(white: 1.0, alpha: 0.7).setFill()

        path.fill()
    }
    
    
}



